﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DIProject.Util
{
    /// <summary>
    /// Класс для общих функций программы.
    /// </summary>
    public class Common
    {
        /// <summary>
        /// Возвращает только дату без времени
        /// </summary>
        public static DateTime CurrentSmallDate
        {
            get
            {
                DateTime dt = DateTime.Now;
                DateTime result = new DateTime(dt.Year, dt.Month, dt.Day);
                return result;
            }
        }
        public static DateTime ConvertToSmall(DateTime date)
        {
            DateTime result = new DateTime(date.Year, date.Month, date.Day);
            return result;
        }
		public static bool HasChanges(System.Data.DataSet dataSet)
		{	for(int i = 0, n = dataSet.Tables.Count; i < n; ++i)
				if(HasChanges(dataSet.Tables[i]))
					return true;
			return false;
		}
		public static bool HasChanges(System.Data.DataTable table)
		{	System.Data.DataRowState rowStates = System.Data.DataRowState.Added | System.Data.DataRowState.Deleted | System.Data.DataRowState.Modified;
			for(int j = 0, m = table.Rows.Count; j < m; ++j)
				if((table.Rows[j].RowState & rowStates) != 0)
					return true;
			return false;
		}
	}
/*	См. DIProjectBase
	public enum ActionType
	{
		NoAction = 0,
		Select = 1,
		Insert = 2,
		Update = 3,
		Delete = 4
	}
*/
}
